<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>结伴明细</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/travelContent.css"/>
    <link href="https://css.mafengwo.net/mobile/css/together/together.css?1526627473" rel="stylesheet" type="text/css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>

    <script>
        $(function () {
            var param = getParams();
            $.get("/companions/" + param.id, function (data) {
                console.log(data);
                var  length = data.users.length;
                $("#length").html(length)
                $(".companion").renderValues(data, {
                    getHref: function (item, value) {
                        var href = $(item).data("href");
                        $(item).attr("href", href + value);
                    }
                })
            })
        })
    </script>
</head>
<body>
<!--<div class="search-head">-->
    <!--<div class="row nav-search">-->
        <!--<div class="col">-->
            <!--<a href="javascript:history.go(-1);">-->
                <!--<span><i class="fa fa-chevron-left"></i></span>-->
            <!--</a>-->
        <!--</div>-->
        <!--<div class="col">-->
            <!--<div class="rBtn">-->
                <!--<a href="/index.html" class="home">首页</a>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
<!--</div>-->
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span></span>
        </div>
        <div class="col">
                <a href="/index.html" class="home">首页</a>
        </div>
    </div>
</div>

<div class="companion">
    <img class="cover" render-src="coverUrl">
    <div class="container">
        <h6 class="title" render-html="title"></h6>
        <small>
            <!--<span render-html="lastUpdateTime"></span>-->
            浏览 <span> 0</span>
            回复 <span> 0</span>
        </small>
        <div class="row">
            <div class="col-2 img">
                <a data-href="userProfiles.html?id=" render-key="author.id" render-fun="getHref">
                    <img class="rounded-circle" render-src="author.headImgUrl" width="40px">
                </a>
            </div>
            <div class="col-6 mine">
                <small>
                    <a data-href="userProfiles.html?id=" render-key="author.id" render-fun="getHref">
                        <span render-html="author.nickName"></span>
                    </a>
                    <button class="btn" id="followBtn">关注</button>
                    <br>
                    <span>0 </span>粉丝
                </small>
            </div>
        </div>
    </div>

    <div class="container">
        <fieldset>
            <legend>我的结伴信息</legend>
            <div class="d-flex">
                <div class="p-2  flex-fill">
                    <i class="fa fa-calendar"></i> 出发时间 <span render-html="goTime"></span>
                </div>
                <div class="p-2  flex-fill"><i class="fa fa-clock-o"></i> 出行天数
                    <span render-html="days">1</span>
                </div>
            </div>
            <div class="d-flex">
                <div class="p-2  flex-fill">
                    <i class="fa fa-map-marker"></i> 地区
                    <span render-html="place"></span>
                </div>

            </div>
        </fieldset>

        <div class="content" render-html="request.request">

        </div>
    </div>

    <hr>
    <dl class="user-list" >
        已报名(<span id="length"></span>)人
        <dd>
            <ul style="width:450px" render-loop="users">
                <li class="_j_set_width"><a href="/together/myself/30743528.html">
                    <img render-src="users.headImgUrl"></a>
                </li>
            </ul>
        </dd>
    </dl>
    <div class="container d-flex">
        <div class="p-2  flex-fill">
            <i class="fa fa-thumbs-o-up" id="likeBtn"> </i>
        </div>
        <div class="p-2  flex-fill"><i class="fa  fa-commenting-o" id="commentBtn"> </i>
        </div>
        <div class="p-2  flex-fill"><i class="fa fa-star-o" id="collectBtn"> </i>
        </div>
    </div>
</div>

<div class="fixed-btm">
    <div class="btn-group">
        <span class="space"></span>
        <a  class="btn-join" id="apply" >我要报名</a>
    </div>
</div>
<script>
    $(function () {

        var  user=JSON.parse(sessionStorage.getItem("user"));

        $("#apply").click(function () {
            if (user == null) {
                window.location.href="/login.html";
            }else {
                $.get("/users/companion",{companionId:getParams().id},function (data) {
                    console.log(data);
                    if (!data) {
                        console.log(1);
                        window.location.href="/mine/apply.html?id="+getParams().id;
                    }else {
                        console.log(11111);
                        $(document).dialog({
                            autoClose: 1200,
                            content: '亲,您已经报过名了'
                        });
                        setTimeout(function () {
                            window.location.reload();
                        }, 1500);
                    }
                })
            }
        })
    })
</script>

</body>

</html>